package com.laboratory.string;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class TestB {
    public static void main(String[] args) throws Exception{
        byte[] bytes = "中".getBytes(StandardCharsets.ISO_8859_1);
        System.out.println("bytes = " + bytes);
        String s = new String(bytes, StandardCharsets.ISO_8859_1);
        System.out.println("s = " + s);

        String s1 = new String("中".getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
        System.out.println("s1 = " + s1);

        String s2 = new String(s1.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
        System.out.println("s2 = " + s2);

        byte[] bytes1 = new byte[]{10};
        String gbk = new String(bytes1, "GBK");
        System.out.println("gbk =" + gbk.toString());

        byte[] bytes2 = new byte[]{13};
        String gbk2 = new String(bytes2, "GBK");
        System.out.println("gbk2 =" + gbk.toString());

        byte[] bytes3 = "|@|".getBytes(StandardCharsets.UTF_8);
        System.out.println("Arrays.toString(bytes3) = " + Arrays.toString(bytes3));
        String s3 = new String(bytes3, StandardCharsets.UTF_8);
        System.out.println("s3 = " + s3);

        byte[] bytes4 = "中".getBytes(StandardCharsets.UTF_8);
        System.out.println("Arrays.toString(bytes4) = " + Arrays.toString(bytes4));
        String s4 = new String(bytes4, StandardCharsets.UTF_8);
        System.out.println("s4 = " + s4);

    }
    

}
